//
//  BaseTableViewController.swift
//  MicroBlog
//
//  Created by Jokin on 2017/3/27.
//  Copyright © 2017年 jokin. All rights reserved.
//

import UIKit

class BaseTableViewController: UITableViewController {

    var isLogIn: Bool = TXUserAccountViewModel.shareUserViewModel.isLogin
    
    var visitorView: TXVisitorView?
    
    override func loadView() {
        if isLogIn {
            super.loadView()
        }else {
            creatUI()
            visitorView = TXVisitorView()
            visitorView?.callBack = { [weak self] in
                self?.enterLogin()
            }
            view = visitorView
        }

    }
    
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        
        
        
    }
    func creatUI()  {
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", imageName: nil, target: self, action: #selector(registerBtnAction))
       
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登陆", imageName: nil, target: self, action: #selector(logInBtnAction))
        
    }

    
    func logInBtnAction() {
        
        enterLogin()
    }
    
    
    func registerBtnAction() {
        
        enterLogin()
    }
    
    func enterLogin()  {
        let Oauth = TXOAuthViewController()
        let navVC = UINavigationController(rootViewController: Oauth)
        
        present(navVC, animated: true, completion: nil)
        
        print("进入登陆页面")
    }
    


}
